from handler_helpers.base_handler_helper import BaseHandlerHelper
from utils.check_params_utlil import CheckParams


class AddHandlerHelper(BaseHandlerHelper):

    def add_handler(self):
        check_r = CheckParams(params=self.request.request_data,
                              conditions=self._get_conditions).check()
        if not check_r.is_success:
            return self._failure_response(message=check_r.message)
        res = self.bll_cls(request=self.request, cls=self.cls, unique_fields=self._get_unique_fields).\
            create(**check_r.data)
        return self._response(res)
